<?php
/**
 * comments table
 * model that supports
 * comments
 * @uses Model_Commentor_User
 * @uses Model_Commentor_Site
 */
 class Model_Commentor_Comment extends Model_Base
{
/*--------------------------------------[properties]--------------------------------------*/

    /**
     * table name
     * must be set within each object
     *
     * @access protected
     */
    protected $tableName = 'comments';


    /**
     * unique id
     * must be set within each object
     *
     * @access protected
     */
    protected $keys = 'id';

    /**
     * the internal data KEY array
     * used for internal objects/values attached to this object
     * MUST BE SET BEFORE HAND
     *
     * @format array['name' => 'type']
     * @access protected
     * @var    array
     */
    protected $internalVars = array(
       'site_id' => 'int',
       'article_id' => 'int',
       'user_id' => 'int',
       'title' => 'str',
       'comment' => 'text',
       'created_by' => 'str',
       'active' => 'str',
    );


    /**
     * the external data KEY array
     * used for external objects/values attached to this object
     * so it doesn't ruin the rawData which will be used to save into db
     * IT STORES ONLY THE KEYS - SO WHEN USING GETRAWDATA, THESE ARE EXEMPTED
     * MUST BE SET BEFORE HAND
     *
     * @format array['name' => 'type']
     * @access protected
     * @var    array
     */
    protected $externalVars = array(
       'site' => 'Model_Commentor_Site',
       'user' => 'Model_Commentor_User',
    );


/*--------------------------------------[getters]--------------------------------------*/

    /**
     * get site_id: id of site
     *
     * @return int
     */
    public function getSiteId()
    {
        return $this->_getVar('site_id');

    }// end getSiteId


    /**
     * get article_id: id of article
     *
     * @return int
     */
    public function getArticleId()
    {
        return $this->_getVar('article_id');

    }// end getArticleId


    /**
     * get user_id: id of user
     *
     * @return int
     */
    public function getUserId()
    {
        return $this->_getVar('user_id');

    }// end getUserId


    /**
     * get title: title of comment
     *
     * @return str
     */
    public function getTitle()
    {
        return $this->_getVar('title');

    }// end getTitle


    /**
     * get comment: comment body
     *
     * @return text
     */
    public function getComment()
    {
        return $this->_getVar('comment');

    }// end getComment


    /**
     * get created_by: date time, in utc
     *
     * @return str
     */
    public function getCreatedBy($difference = 0, $format = 'Y-m-d H:i:s')
    {
        return Util_Date::getDateByTimezone($this->_getVar('created_by'), $difference, $format);

    }// end getCreatedBy


    /**
     * get active: Y|N
     *
     * @return str
     */
    public function getActive()
    {
        return $this->_getVar('active') == 'Y';

    }// end getActive


    /**
     * get site: the site object
     *
     * @return Model_Commentor_Site
     */
    public function getSite()
    {
        return $this->_getVar('site');

    }// end getSite


    /**
     * get user: the user object
     *
     * @return Model_Commentor_User
     */
    public function getUser()
    {
        return $this->_getVar('user');

    }// end getUser


/*--------------------------------------[setters]--------------------------------------*/

    /**
     * set site_id
     *
     * @param int $SiteId id of site
     *
     * @return Model_Comments
     */
    public function setSiteId($SiteId)
    {
        return $this->_setVar('site_id', $SiteId);

    }// end setSiteId


    /**
     * set article_id
     *
     * @param int $ArticleId id of article
     *
     * @return Model_Comments
     */
    public function setArticleId($ArticleId)
    {
        return $this->_setVar('article_id', $ArticleId);

    }// end setArticleId


    /**
     * set user_id
     *
     * @param int $UserId id of user
     *
     * @return Model_Comments
     */
    public function setUserId($UserId)
    {
        return $this->_setVar('user_id', $UserId);

    }// end setUserId


    /**
     * set title
     *
     * @param str $Title title of comment
     *
     * @return Model_Comments
     */
    public function setTitle($Title)
    {
        return $this->_setVar('title', $Title);

    }// end setTitle


    /**
     * set comment
     *
     * @param text $Comment comment body
     *
     * @return Model_Comments
     */
    public function setComment($Comment)
    {
        return $this->_setVar('comment', $Comment);

    }// end setComment


    /**
     * set created_by
     *
     * @param str $CreatedBy date time, in utc
     *
     * @return Model_Comments
     */
    public function setCreatedBy($CreatedBy)
    {
        return $this->_setVar('created_by', $CreatedBy);

    }// end setCreatedBy


    /**
     * set active
     *
     * @param str $Active Y|N
     *
     * @return Model_Comments
     */
    public function setActive($Active)
    {
        $Active = $Active? 'Y' : 'N';
        return $this->_setVar('active', $Active);

    }// end setActive


    /**
     * set site
     *
     * @param Model_Commentor_Site $Site the site object
     *
     * @return Model_Comments
     */
    public function setSite(Model_Commentor_Site $Site)
    {
        $this->setSiteId($Site->getID());
        return $this->_setVar('site', $Site);

    }// end setSite


    /**
     * set user
     *
     * @param Model_Commentor_User $User the user object
     *
     * @return Model_Comments
     */
    public function setUser(Model_Commentor_User $User)
    {
        $this->setUserId($User->getID());
        return $this->_setVar('user', $User);

    }// end setUser

}
?>